import { Controller, Post, UploadedFile } from '@nestjs/common';
import { uploadsFilter } from 'src/cu-dec';
import { fileTypeCheck } from 'src/utils/fileTypeCheck';

@Controller('file')
export class FileController {
  @Post('img')
  @uploadsFilter('file', {
    fileFilter: fileTypeCheck('image'),
  })
  uploadImg(@UploadedFile() file: Express.Multer.File) {
    return file;
  }

  // .doc,.docx,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document
  @Post('file')
  @uploadsFilter('file', {
    fileFilter: fileTypeCheck(
      'doc',
      'docx',
      'application/msword',
      'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    ),
  })
  uploadDoc(@UploadedFile() file: Express.Multer.File) {
    return file;
  }
}
